public enum TestEnum {
    RED,BLACK,GREEN,WHITE;
    public static void main1(String[] args) {
        TestEnum testEnum2 = TestEnum.BLACK;
        switch (testEnum2) {
            case RED:
                System.out.println("red");
                break;
            case BLACK:
                System.out.println("black");
                break;
            case WHITE:
                System.out.println("WHITE");
                break;
            case GREEN:
                System.out.println("black");
                break;
            default:
                break;
        }

    }
    public static void main2(String[] args) {
        TestEnum[] testEnum2 = TestEnum.values();
        for (int i = 0; i < testEnum2.length; i++) {
            System.out.println(testEnum2[i] + " " + testEnum2[i].ordinal());
        }
        System.out.println("=========================");
        //如果字符串不匹配任何枚举常量名，则抛出 IllegalArgumentException。
        System.out.println(TestEnum.valueOf("GREEN"));
    }
    public static void main(String[] args) {
        /*
        负值：调用的枚举实例位于参数枚举实例之前。
        0：两个枚举实例相同。
        正值：调用的枚举实例位于参数枚举实例之后。
        */
        //拿到枚举实例BLACK
        TestEnum testEnum = TestEnum.BLACK;
        //拿到枚举实例RED
        TestEnum testEnum21 = TestEnum.RED;
        System.out.println(testEnum.compareTo(testEnum21));
        System.out.println(BLACK.compareTo(RED));
        System.out.println(RED.compareTo(BLACK));
    }


}
